<template>
  <div class="list-common-table">
    <t-loading :loading="loading" text="加载中..." fullscreen />
    <t-dialog header="确认删除？" @confirm="deleteTarget(0,'c')" :visible="deleteVisible"
      @cancel="()=>{deleteIdx=[] ;deleteVisible=false}" :onClose="()=>{deleteIdx=[] ;deleteVisible=false}" />

    <t-dialog header="添加" :visible="addVisible"
      @cancel="()=>{addInfo={} ;addVisible=false;targetTemp=[[],[]];postDate=[];addTargetVisible=false;addMediVisible=false;}"
      :onClose="()=>{addInfo={} ;addVisible=false;targetTemp=[[],[]];postDate=[];addTargetVisible=false;addMediVisible=false;}"
      @confirm="addTarget('t')">
      <t-date-picker mode="date" range format="YYYY-MM-DD HH:mm:ss" clearable @pick="onPick" @change="dataChange" />
      <t-card title="饮食"><template #actions>
          <t-button @click="setVisible('t')" v-show="!addTargetVisible">添加</t-button>
        </template>
        <t-form v-show="addTargetVisible">
          <t-form-item label="名字">
            <t-input v-model="singleAddInfo.name"></t-input>
          </t-form-item>
          <t-form-item label="数量" v-model="singleAddInfo.name">
            <t-input-number v-model="singleAddInfo.quantity" :decimal-places="2"></t-input-number>
          </t-form-item>
          <t-form-item label="单位">
            <t-input v-model="singleAddInfo.unit"></t-input>
          </t-form-item>
          <t-form-item>
            <t-button theme="primary" @click="saveTemp('t',0)">添加</t-button>
            <t-button theme="default" @click="() => {addTargetVisible = false;singleAddInfo={}}">取消</t-button>
          </t-form-item>
        </t-form>
        <t-list :split="true" size="small">
          <t-list-item v-for="(item,index) in targetTemp[0]">
            <t-list-item-meta :title="item.name + ' ' + item.quantity+item.unit"></t-list-item-meta>
          </t-list-item>
        </t-list>
      </t-card>
      <t-card title="用药"><template #actions>
          <t-button @click="setVisible('m')" v-show="!addMediVisible">添加</t-button>
        </template>
        <t-form v-show="addMediVisible">
          <t-form-item label="名字">
            <t-input v-model="singleAddInfo.name"></t-input>
          </t-form-item>
          <t-form-item label="数量" v-model="singleAddInfo.name">
            <t-input-number v-model="singleAddInfo.quantity" :decimal-places="2"></t-input-number>
          </t-form-item>
          <t-form-item label="单位">
            <t-input v-model="singleAddInfo.unit"></t-input>
          </t-form-item>
          <t-form-item>
            <t-button theme="primary" @click="saveTemp('m',1)">添加</t-button>
            <t-button theme="default" @click="() => {addMediVisible = false;singleAddInfo={}}">取消</t-button>
          </t-form-item>
        </t-form>
        <t-list :split="true" size="small">
          <t-list-item v-for="(item,index) in targetTemp[1]">
            <t-list-item-meta :title="item.name + ' ' + item.quantity+item.unit"></t-list-item-meta>
          </t-list-item>
        </t-list>
      </t-card>
    </t-dialog>

    <t-dialog header="添加" :visible="addWorkVisible"
      @cancel="()=>{addInfo={} ;addWorkVisible=false;addKangzuVisible=false;addRourenVisible=false;addYouyangVisible;workTemp=[[],[],[]];postDate=[];}"
      :onClose="()=>{addInfo={} ;addWorkVisible=false;addKangzuVisible=false;addRourenVisible=false;addYouyangVisible;workTemp=[[],[],[]];postDate=[];}"
      @confirm="addTarget('w')">
      <t-date-picker mode="date" range format="YYYY-MM-DD HH:mm:ss" clearable @pick="onPick" @change="dataChange" />
      <t-card title="抗阻">
        <t-list>
          <t-list-item v-for="(item,index) in work[0]" :key="index">
            <t-list-item-meta :title="item.name"
              :description="'每次/分钟分数 '+item.pointPerTime+'，设定分数 '+item.time*item.pointPerTime" />
            <template #action>
              <t-switch v-model="item.checked"></t-switch>
            </template>
            <t-input-number v-show="item.checked" v-model="item.time"></t-input-number>
          </t-list-item>
        </t-list>
      </t-card>
      <t-card title="有氧">
        <t-list>
          <t-list-item v-for="(item,index) in work[1]" :key="index">
            <t-list-item-meta :title="item.name"
              :description="'每次/分钟分数 '+item.pointPerTime+'，设定分数 '+item.time*item.pointPerTime" />
            <template #action>
              <t-switch v-model="item.checked"></t-switch>
            </template>
            <t-input-number v-show="item.checked" v-model="item.time"></t-input-number>
          </t-list-item>
        </t-list>
      </t-card>
      <t-card title="柔韧">
        <t-list>
          <t-list-item v-for="(item,index) in work[2]" :key="index">
            <t-list-item-meta :title="item.name"
              :description="'每次/分钟分数 '+item.pointPerTime+'，设定分数 '+item.time*item.pointPerTime" />
            <template #action>
              <t-switch v-model="item.checked"></t-switch>
            </template>
            <t-input-number v-show="item.checked" v-model="item.time">次/分钟</t-input-number>
          </t-list-item>
        </t-list>
      </t-card>
    </t-dialog>

    <t-drawer :visible="infoVisible" size="80%" :onCancel="closeInfo" :onClose="closeInfo">
      <t-card title="基础信息">
        <t-row justify="space-around" align="middle" :gutter="[12,12]">
          <t-col :span="5">
            <t-card title="姓名">
              {{pat.name}}
            </t-card>
          </t-col>
          <t-col :span="5">
            <t-card title="性别">
              {{pat.sex}}
            </t-card>
          </t-col>
          <t-col :span="5">
            <t-card title="手术类型">
              {{pat.opType}}
            </t-card>
          </t-col>
          <t-col :span="5">
            <t-card title="生日">
              {{pat.birth}}
            </t-card>
          </t-col>
          <t-col :span="5">
            <t-card title="创建时间">
              {{pat.createTime}}
            </t-card>
          </t-col>
          <t-col :span="5">
            <t-card title="上次复查时间">
              {{pat.lastCheckTime}}
            </t-card>
          </t-col>
        </t-row>
      </t-card>
      <t-card title="上一次紧急信息打开时间" style="margin-top: 12px;">
        <div class="contract-detail">{{emerGet.time}}</div>
      </t-card>
      <t-card title="生活打卡目标" style="margin-top: 12px;"><template #actions>
          <t-button @click="()=>{addVisible=true}">添加</t-button>
        </template>
        <view v-show="false">{{tL}}</view>
        <t-card v-for="(item,index) in tL" :title="item.createTime" :description="item.validity">
          <template #actions>
            <t-button @click="deleteTarget(index,'t')">删除</t-button>
          </template>
          <t-card v-for="(item2,index2) in item.targetList" :title="item2.type">
            <t-list :split="true">
              <t-list-item v-for="(item3,index3) in item2.list">
                <t-list-item-meta :title="item3.name" :description="item3.quantity+item3.unit"></t-list-item-meta>
              </t-list-item>
            </t-list>
          </t-card>
        </t-card>
      </t-card>
      <t-card title="运动打卡目标" style="margin-top: 12px;"><template #actions>
          <t-button @click="()=>{addWorkVisible=true}">添加</t-button>
        </template>
        <view v-show="false">{{wL}}</view>
        <t-card v-for="(item,index) in wL" :title="item.createTime" :description="item.validity">
          <template #actions>
            <t-button @click="deleteTarget(index,'w')">删除</t-button>
          </template>
          <t-card v-for="(item2,index2,i2) in item.avaliableList" :title="index2">
            <t-list :split="true">
              <t-list-item v-for="(item3,index3) in item2.list">
                <t-list-item-meta :title="item3.name" :description="'每次/分钟分数：'+item3.pointPerTime"></t-list-item-meta>
                目标：{{item2.target[index3]}}
              </t-list-item>
            </t-list>
          </t-card>
        </t-card>
      </t-card>
    </t-drawer>

    <t-form ref="form" :data="formData" :label-width="80" colon @reset="onReset" @submit="onSubmit">
      <t-row>
        <t-col :span="10">
          <t-row :gutter="[16, 16]">
            <t-col :flex="1">
              <t-form-item label="性别" name="status">
                <t-select v-model="formData.sex" class="form-item-content`" :options="SEX_STATUS_OPTIONS"
                  placeholder="" />
              </t-form-item>
            </t-col>
            <t-col :flex="1">
              <t-form-item label="姓名" name="name">
                <t-input v-model="formData.name" class="form-item-content" placeholder="请输入姓名" />
              </t-form-item>
            </t-col>
            <!--            <t-col :flex="1">
              <t-form-item label="工单类型" name="type">
                <t-select v-model="formData.type" class="form-item-content`" :options="CONTRACT_TYPE_OPTIONS" placeholder="请选择工单类型" />
              </t-form-item>
            </t-col> -->
          </t-row>
        </t-col>

        <t-col :span="2" class="operation-container">
          <t-button theme="primary" type="submit" :style="{ marginLeft: '8px' }">查询</t-button>
          <t-button type="reset" variant="base" theme="default">重置</t-button>
        </t-col>
      </t-row>
    </t-form>
    <div class="table-container">
      <t-table :data="data" :columns="columns" :rowKey="rowKey" :stripe="defaultTrue" :verticalAlign="verticalAlign"
        :hover="hover" :pagination="pagination" @page-change="rehandlePageChange" @change="rehandleChange"
        :loading="dataLoading">
        <!-- <template #status="{ row }">
          <t-tag v-if="row.review === ARTICLE_STATUS.POSTED" theme="danger" variant="light">待审核</t-tag>
          <t-tag v-if="row.review === ARTICLE_STATUS.ALLOWED" theme="success" variant="light">审核通过</t-tag>
          <t-tag v-if="row.review === ARTICLE_STATUS.CLOSED" variant="light">未通过</t-tag>
        </template> -->
        <template #name="{ row }">
          {{ row.name }}
          <t-icon :name="row.sex=='男'?'gender-male':'gender-female'" />
        </template>

        <!--        <template #contractType="{ row }">
          <p v-if="row.contractType === CONTRACT_TYPES.MAIN">审核失败</p>
          <p v-if="row.contractType === CONTRACT_TYPES.SUB">待审核</p>
          <p v-if="row.contractType === CONTRACT_TYPES.SUPPLEMENT">待履行</p>
        </template> -->
        <!--        <template #paymentType="{ row }">
          <p v-if="row.paymentType === CONTRACT_PAYMENT_TYPES.PAYMENT" class="payment-col">
            付款
            <trend class="dashboard-item-trend" type="up" />
          </p>
          <p v-if="row.paymentType === CONTRACT_PAYMENT_TYPES.RECIPT" class="payment-col">
            收款
            <trend class="dashboard-item-trend" type="down" />
          </p>
        </template> -->
        <template #op="slotProps">
          <t-button @click="rehandleClickOp(slotProps, 'info')" shape="circle">
            <t-icon name="browse"></t-icon>
          </t-button>
          <!-- <a class="t-button-link" @click="rehandleClickOp(slotProps, 'info')">查看</a>
          <a class="t-button-link" @click="rehandleClickOp(slotProps, 'modi')" v-show="manager && row.status === ARTICLE_STATUS.POSTED">回复</a> -->
          <!-- <a class="t-button-link" @click="handleClickDelete(slotProps)">删除</a> -->
        </template>
      </t-table>
      <!-- <t-dialog header="确认删除当前所选合同？" :body="confirmBody" :visible.sync="confirmVisible" @confirm="onConfirmDelete" :onCancel="onCancel"></t-dialog> -->
    </div>
  </div>
</template>

<script>
  import {
    prefix
  } from '@/config/global';
  import Trend from '@/components/trend/index.vue';
  import Card from '@/components/card/index.vue';
  import {
    SEX_STATUS,
    SEX_STATUS_OPTIONS
  } from '@/constants/index'

  export default {
    name: 'list-table',
    components: {
      Trend,
      Card
    },
    data() {
      return {
        postDate: [],
        targetTemp: [
          [],
          []
        ],
        workTemp: [
          [],
          [],
          []
        ],
        emer: {},
        emerGet: {},
        wL: {},
        tL: {},
        wwL: {},
        ttL: {},
        pat: {},
        work: [
          [],
          [],
          []
        ],
        addInfo: {},
        singleAddInfo: {},
        patientInfo: {},
        infoVisible: false,
        defaultTrue: true,
        postValue: '',
        prefix,
        formData: {
          name: '',
          sex: ''
        },
        data: [],
        dataLoading: false,
        value: 'first',
        columns: [{
            title: '姓名',
            width: 125,
            fixed: 'left',
            ellipsis: true,
            colKey: 'name'
          },
          {
            title: '生日',
            // minWidth: '300',
            align: 'left',
            // ellipsis: true,
            colKey: 'birth',
            width: 125
          },
          {
            title: '手术术式',
            colKey: 'opType',
            width: 125,
            cell: {
              col: 'opType'
            }
          },

          {
            title: '最近一次就诊',
            colKey: 'lastCheckTime',
            width: 150,
            cell: {
              col: 'lastCheckTime'
            }
          },
          // {
          //   title: '合同类型',
          //   width: 200,
          //   ellipsis: true,
          //   colKey: 'contractType'
          // },
          // {
          //   title: '合同收付类型',
          //   width: 200,
          //   ellipsis: true,
          //   colKey: 'paymentType'
          // },
          // {
          //   title: '合同金额 (元)',
          //   width: 200,
          //   ellipsis: true,
          //   colKey: 'amount'
          // },
          {
            align: 'center',
            fixed: 'right',
            width: 100,
            colKey: 'op',
            title: '操作'
          }
        ],
        rowKey: 'index',
        tableLayout: 'auto',
        verticalAlign: 'top',
        bordered: true,
        hover: true,
        rowClassName: rowKey => `${rowKey}-class`,
        // 与pagination对齐
        pagination: {
          defaultPageSize: 10,
          total: 100,
          defaultCurrent: 1,
          pageSizeOptions: [5, 10, 20, 50]
        },
        SEX_STATUS,
        SEX_STATUS_OPTIONS,
        pages: {
          current: 1,
          pageSize: 10
        },
        deleteIdx: -1,
        loading: false,
        tLopen: [],
        wLopen: [],
        deleteVisible: false,
        addVisible: false,
        addWorkVisible: false,
        addTargetVisible: false,
        addMediVisible: false,
        addKangzuVisible: false,
        addYouyangVisible: false,
        addRourenVisible: false
      };
    },
    computed: {
      // confirmBody() {
      //   if (this.deleteIdx > -1) {
      //     const { name } = this.data?.[this.deleteIdx];
      //     return `删除后，${name}的所有合同信息将被清空，且无法恢复`;
      //   }
      //   return '';
      // }
    },
    async created() {
      // console.log(this.$store.state.user.userInfo.type)
      if (localStorage.getItem('ovcf-token') != undefined) {
        console.log('set token');
        this.$store.commit('user/setToken', localStorage.getItem('ovcf-token'));
        this.$store.commit('user/setUserInfo', JSON.parse(localStorage.getItem('info')));
      }
      this.dataLoading = true;
      await this.$request
        .post('/doctor-patient?type=list&pageSize=10&current=1', {})
        .then(res => {
          if (res.code === 0) {
            console.log(res);
            this.pagination.total = res.count;
            this.data = res.info;
          } else {
            this.$message.error(res.info)
          }
        })
        .catch(e => {
          this.$message.error('错误！');
          console.log(e);
        })
        .finally(() => {
          this.dataLoading = false;
        });
    },
    methods: {
      saveTemp(type, position) {
        console.log("save temp", type, position)
        console.log(this.singleAddInfo)
        switch (type) {
          case "t": {
            if (JSON.stringify(this.singleAddInfo) == "{}") {
              this.$message.error("有选项未填写，请检查！")
              return
            }
            let count = 0
            for (let item in this.singleAddInfo) {
              count++
              if (this.singleAddInfo[item] == '') {
                this.$message.error("有选项未填写，请检查！")
                return
              }
            }
            if (count != 3) {
              this.$message.error("有选项未填写，请检查！")
              return
            }
            this.targetTemp[position].push(JSON.parse(JSON.stringify(this.singleAddInfo)))
            this.targetTemp[position][this.targetTemp[position].length - 1].type = "饮食"
            this.addTargetVisible = false;
            this.singleAddInfo = {}
            break;
          }
          case "m": {
            if (JSON.stringify(this.singleAddInfo) == "{}") {
              this.$message.error("有选项未填写，请检查！")
              return
            }
            let count = 0
            for (let item in this.singleAddInfo) {
              count++
              if (this.singleAddInfo[item] == '') {
                this.$message.error("有选项未填写，请检查！")
                return
              }
            }
            if (count != 3) {
              this.$message.error("有选项未填写，请检查！")
              return
            }
            for (let item in this.singleAddInfo) {
              if (this.singleAddInfo[item] == undefined || this.singleAddInfo[item] == "") {
                this.$message.error("有选项未填写，请检查！")
                break
              }
            }
            this.targetTemp[position].push(JSON.parse(JSON.stringify(this.singleAddInfo)))
            this.targetTemp[position][this.targetTemp[position].length - 1].type = "用药"
            this.addMediVisible = false;
            this.singleAddInfo = {}
            break;
          }
        }
      },
      setVisible(type) {
        switch (type) {
          case "t": {
            this.addTargetVisible = true;
            break;
          }
          case "m": {
            this.addMediVisible = true;
            break;
          }
        }
      },
      onPick(value, content) {
        console.log("pick date", value, content)
      },
      dataChange(value) {
        console.log("change date", value)
        if (value.length != 2) this.postDate = []
        else {
          console.log("setDate")
          this.postDate = value
        }
      },
      addTarget(type) {
        switch (type) {
          case "t": {
            if (this.postDate.length != 2) {
              this.$message.error("请正确输入生效期！")
              break
            }
            this.$request.post("/doctor-patient?type=addTarget", {
                content: this.targetTemp,
                time: this.postDate,
                PID: this.pat.PID
              }).then(res => {
                console.log(res);
                if (res.code == 0) {
                  this.$message.success("提交成功！");
                  this.addInfo = {};
                  this.addVisible = false;
                  this.targetTemp = [
                    [],
                    []
                  ];
                  this.postDate = [];
                  this.addTargetVisible = false;
                  this.addMediVisible = false;
                  this.rehandleClickOp({
                    text: undefined,
                    row: this.pat
                  }, "info")
                } else {
                  this.$message.error(res.info)
                }
              })
              .catch(e => {
                this.$message.error('错误！');
                console.log(e);
              })
              .finally(() => {});;
            break;
          }
          case 'w': {
            if (this.postDate.length != 2) {
              this.$message.error("请正确输入生效期！")
              return
            }
            let workList = []
            let total = 0
            for (let i = 0; i < this.work.length; i++) {
              workList.push([])
              for (let j = 0; j < this.work[i].length; j++) {
                if (this.work[i][j].checked == true) {
                  if (this.work[i][j].time == 0) {
                    this.$message.error("有次数/时间为0的选项，请检查！")
                    return
                  }
                  total++;
                  workList[i].push(this.work[i][j])
                }
              }
            }
            console.log(workList)
            if (total == 0) {
              this.$message.error("未选择运动，请检查！")
            }
            this.$request.post('/doctor-patient?type=addWork', {
              content: workList,
              PID: this.pat.PID,
              time: this.postDate
            }).then((res) => {
              console.log(res)
              if (res.code == 0) {
                this.$message.success("提交成功！");
                this.addWorkVisible = false;
                this.postDate = []
              } else {
                this.$message.error("错误！");
              }
            }).catch(e => {
              this.$message.error('错误！');
              console.log(e);
            }).finally(() => {});;
          }
        }
      },
      async deleteTarget(index, type) {
        if (type == "t" || type == "w") {
          this.deleteIdx = [index, type]
          this.deleteVisible = true
        } else {
          console.log(this.deleteIdx)
          if (this.deleteIdx[1] == "t") {
            await this.$request
              .post('/doctor-patient?type=delTar', {
                _id: this.tL[this.deleteIdx[0]]._id
              })
              .then(res => {
                console.log(res);
                if (res.data.code == 1) {
                  console.log("delete", this.deleteIdx[0])
                  this.tL.splice(this.deleteIdx[0], 1)
                } else {
                  this.$message.error(res.info)
                }
              })
              .catch(e => {
                this.$message.error('错误！');
                console.log(e);
              })
              .finally(() => {});
          }
          if (this.deleteIdx[1] == "w") {
            await this.$request
              .post('/doctor-patient?type=delWor', {
                _id: this.wL[this.deleteIdx[0]]._id
              })
              .then(res => {
                console.log(res);
                if (res.data.code == 1) {
                  console.log("delete", this.deleteIdx[0])
                  this.wL.splice(this.deleteIdx[0], 1)
                } else {
                  this.$message.error(res.info)
                }
              })
              .catch(e => {
                this.$message.error('错误！');
                console.log(e);
              })
              .finally(() => {});
          }
          this.deleteIdx = []
          this.deleteVisible = false
        }
      },
      closeInfo() {
        this.infoVisible = false;
        this.emer = {}
        this.emerGet = {}
        this.wL = {}
        this.tL = {}
        this.pat = {}
        this.deleteIdx = 0
        this.addVisible = false
        this.addWorkVisible = false
        this.tLopen = []
        this.wLopen = []
        this.targetTemp = [{}, {}]
        this.workTemp = [{}, {}, {}]
        this.work = [
          [],
          [],
          []
        ]
      },
      async postWorkorder(type) {
        if (type == 'new') {
          this.$request
            .post('/doctor-patient?type=modi', {
              content: this.postValue
            })
            .then(res => {
              if (res.code === 0) {
                this.$message.success('提交成功！');
                // this.onSubmit();
                // this.closeInfo();
              } else {
                this.$message.error(res.data.info);
              }
            })
            .catch(e => {
              this.$message.error('提交失败！');
              console.log(e);
            })
            .finally(() => {
              this.onSubmit();
              this.closeInfo();
            });
        }
      },
      onReset(data) {
        this.formData.sex = ''
        console.log(data);
      },
      async onSubmit(data) {
        console.log(this.formData);
        this.pagination.current = 1;
        this.$request
          .post('/doctor-patient?type=list&pageSize=' + this.pages.pageSize + '&current=' + this.pages.current, this
            .formData)
          .then(res => {
            if (res.code === 0) {
              console.log(res);
              this.pagination.total = res.count;
              this.data = res.data;
              // } else {
              //   let reg = new RegExp('[\\s\\S]*' + this.formData.content + '[\\s\\S]*', 'i');
              //   // console.log(reg)
              //   this.data = res.info.filter(item => {
              //     if (reg.test(item.info)) {
              //       return item;
              //     }
              //   });
            } else {
              this.$message.error(res.info)
            }
          })
          .catch(e => {
            this.$message.error('错误！');
            console.log(e);
          })
          .finally(() => {
            this.dataLoading = false;
          });
      },
      async rehandlePageChange(curr, pageInfo) {
        console.log('分页变化', curr, pageInfo);
        this.pages.pageSize = curr.pageSize;
        this.pages.current = curr.current;
        await this.onSubmit();
      },
      rehandleChange(changeParams, triggerAndData) {
        console.log('统一Change', changeParams, triggerAndData);
      },
      rehandleClickOp({
        text,
        row
      }, type) {
        this.loading = true;
        console.log(text, row);
        if (type == 'info') {
          this.infoVisible = true;
          this.$request
            .post('/doctor-patient?type=info', {
              PID: row.PID
            })
            .then(res => {
              if (res.code == 0) {
                console.log(res)
                this.pat = row
                this.emer = res.emer
                this.emerGet = res.emerGet
                this.wL = res.wL
                this.tL = res.tL
                this.wwL = res.wwL
                this.ttL = res.ttL
                for (let i = 0; i < this.wL.length; i++) {
                  // console.log("i", i)
                  this.wLopen.push([])
                  for (let j in this.wL[i].avaliableList) {
                    // console.log("j", j)
                    for (let n = 0; n < this.wL[i].avaliableList[j].list.length; n++) {
                      // console.log("n", n)
                      for (let m = 0; m < this.wwL.length; m++) {
                        // console.log("m", m)
                        if (this.wwL[m]._id == this.wL[i].avaliableList[j].list[n]) {
                          this.wL[i].avaliableList[j].list[n] = this.wwL[m]
                        }
                      }
                    }
                  }
                }
                for (let i = 0; i < this.tL.length; i++) {
                  this.tLopen.push([])
                  for (let j = 0; j < this.tL[i].targetList.length; j++) {
                    for (let n = 0; n < this.ttL.length; n++) {
                      if (this.ttL[n].STID == this.tL[i].targetList[j]) {
                        this.tL[i].targetList[j] = this.ttL[n]
                      }
                    }
                  }
                }
                for (let i = 0; i < this.wwL.length; i++) {
                  let j = 0;
                  switch (this.wwL[i].type) {
                    case "抗阻": {
                      j = 0;
                      break;
                    }
                    case "有氧": {
                      j = 1;
                      break;
                    }
                    case "柔韧": {
                      j = 2;
                      break;
                    }
                  }
                  let tempw = JSON.parse(JSON.stringify(this.wwL[i]))
                  tempw.checked = false;
                  tempw.time = 0;
                  this.work[j].push(tempw)
                }
              } else {
                this.$message.error(res.info)
              }
            })
            .catch(e => {
              this.$message.error('错误！');
              console.log(e);
            })
            .finally(() => {
              this.loading = false;
            })
        }
      },
      handleClickDelete(row) {
        this.deleteIdx = row.rowIndex;
        this.confirmVisible = true;
      }
      // onConfirmDelete() {
      //   // 真实业务请发起请求
      //   this.data.splice(this.deleteIdx, 1);
      //   this.pagination.total = this.data.length;
      //   this.confirmVisible = false;
      //   this.$message.success('删除成功');
      //   this.resetIdx();
      // },
      // onCancel() {
      //   this.resetIdx();
      // },
      // resetIdx() {
      //   this.deleteIdx = -1;
      // }
    }
  };
</script>

<style lang="less">
  @import './index.less';

  .list-common-table {
    background-color: @bg-color-container;
    padding: 30px 32px;
    border-radius: @border-radius;

    .table-container {
      margin-top: 30px;
    }
  }

  .form-item-content {
    width: 100%;
  }

  .operation-container {
    display: flex;
    justify-content: flex-end;
    align-items: center;
  }

  .payment-col {
    display: flex;

    .trend-container {
      display: flex;
      align-items: center;
      margin-left: 8px;
    }
  }
</style>
